package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zajb {
   private zoz a = null;
   private HashMap b = null;
   private static final com.aspose.cells.b.c.a.za c = new com.aspose.cells.b.c.a.za(new String[]{"Fallback", "oleItem"});

   zajb(zoz var1, HashMap var2) {
      this.a = var1;
      this.b = var2;
   }

   void a(zcfw var1) throws Exception {
      this.g(var1);
      if (!var1.n()) {
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("externalBook".equals(var1.p())) {
               this.e(var1);
            } else if ("oleLink".equals(var1.p())) {
               this.c(var1);
            } else if ("ddeLink".equals(var1.p())) {
               this.d(var1);
            } else {
               var1.a();
            }
         }

      }
   }

   private void c(zcfw var1) throws Exception {
      String var2 = var1.a("progId");
      String var3 = null;
      String var4 = var1.a("r:id");
      if (var4 != null && this.b != null) {
         zqe var5 = zajh.b(this.b, var4);
         var3 = zbue.b(var5.e);
      }

      zbqg var7 = new zbqg(4);
      if (!var1.n()) {
         var1.d();

         label33:
         while(true) {
            while(true) {
               if (!zass.a(var1)) {
                  break label33;
               }

               if ("oleItems".equals(var1.p()) && !var1.n()) {
                  this.a(var1, var7);
               } else {
                  var1.a();
               }
            }
         }
      } else {
         var1.a();
      }

      if (var2 != null && var3 != null) {
         var7.b(var2, var3);
      }

      int var6 = this.a.a.getWorksheets().v().a(var7);
      this.a.a.getWorksheets().q().b(var6, 65534, 65534);
   }

   private ArrayList a(zcfw var1, zbqg var2) throws Exception {
      ArrayList var3 = var2.b();
      var1.d();

      while(true) {
         label53:
         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else {
               zuk var4;
               if ("oleItem".equals(var1.p())) {
                  var4 = this.c(var1, var2);
                  if (var4 != null) {
                     com.aspose.cells.b.a.a.ze.a(var3, (Object)var4);
                  }
               } else if (!"AlternateContent".equals(var1.p())) {
                  var1.a();
               } else {
                  var1.d();

                  while(true) {
                     while(true) {
                        if (!zass.a(var1)) {
                           continue label53;
                        }

                        switch(c.a(var1.p())) {
                        case 0:
                           var1.d();

                           while(zass.a(var1)) {
                              switch(c.a(var1.p())) {
                              case 1:
                                 var4 = this.c(var1, var2);
                                 if (var4 != null) {
                                    com.aspose.cells.b.a.a.ze.a(var3, (Object)var4);
                                 }
                                 break;
                              default:
                                 var1.a();
                              }
                           }
                           break;
                        default:
                           var1.a();
                        }
                     }
                  }
               }
            }
         }

         var1.h();
         return var3;
      }
   }

   private void d(zcfw var1) throws Exception {
      String var2 = var1.a("ddeService");
      String var3 = var1.a("ddeTopic");
      zbqg var4 = new zbqg(3);
      if (!var1.n()) {
         var1.d();

         label28:
         while(true) {
            while(true) {
               if (!zass.a(var1)) {
                  break label28;
               }

               if ("ddeItems".equals(var1.p()) && !var1.n()) {
                  this.b(var1, var4);
               } else {
                  var1.a();
               }
            }
         }
      } else {
         var1.a();
      }

      if (var2 != null && var3 != null) {
         var4.a(var2, var3);
      }

      int var5 = this.a.a.getWorksheets().v().a(var4);
      this.a.a.getWorksheets().q().b(var5, 65534, 65534);
   }

   private void b(zcfw var1, zbqg var2) throws Exception {
      ArrayList var3 = var2.b();
      var1.d();

      while(var1.r() != 4) {
         var1.j();
         if (var1.r() != 1) {
            var1.a();
         } else if ("ddeItem".equals(var1.p())) {
            zuk var4 = this.c(var1, var2);
            if (var4 != null) {
               com.aspose.cells.b.a.a.ze.a(var3, (Object)var4);
            }
         } else {
            var1.a();
         }
      }

      var1.h();
   }

   private zuk c(zcfw var1, zbqg var2) throws Exception {
      zuk var3 = null;
      if (var1.m()) {
         var3 = new zuk(var2);
         var3.d(var3.g() | 16);

         while(var1.l()) {
            if ("name".equals(var1.p())) {
               var3.a(var1.s());
            } else if ("ole".equals(var1.p())) {
               var3.a(zase.ax(var1.s()));
            } else if ("advise".equals(var1.p())) {
               var3.b(zase.ax(var1.s()));
            } else if ("preferPic".equals(var1.p())) {
               var3.c(zase.ax(var1.s()));
            }
         }

         var1.k();
      }

      var1.a();
      return var3;
   }

   private void e(zcfw var1) throws Exception {
      String var2 = null;
      ArrayList var3 = null;
      String var4 = var1.a("r:id");
      if (var4 != null && this.b != null) {
         zqe var5 = zajh.b(this.b, var4);
         var2 = zbue.b(var5.e);
      }

      zbqg var9 = new zbqg(0);
      int var6 = this.a.a.getWorksheets().v().a(var9);
      if (!var1.n()) {
         var1.d();

         label48:
         while(true) {
            while(true) {
               if (!zass.a(var1)) {
                  break label48;
               }

               if ("sheetNames".equals(var1.p()) && !var1.n()) {
                  var3 = this.f(var1);
                  String[] var7 = new String[var3.size()];

                  for(int var8 = 0; var8 < var3.size(); ++var8) {
                     var7[var8] = (String)var3.get(var8);
                     this.a.a.getWorksheets().q().b(var6, var8, var8);
                  }

                  var9.a(var7);
               } else if ("definedNames".equals(var1.p()) && !var1.n()) {
                  this.f(var1, var9);
               } else if ("sheetDataSet".equals(var1.p()) && !var1.n()) {
                  this.d(var1, var9);
               } else {
                  var1.a();
               }
            }
         }
      } else {
         var1.a();
      }

      var9.e(var2);
   }

   private void d(zcfw var1, zbqg var2) throws Exception {
      var1.d();

      while(var1.r() != 4) {
         var1.j();
         if (var1.r() != 1) {
            var1.a();
         } else if ("sheetData".equals(var1.p())) {
            this.e(var1, var2);
         } else {
            var1.a();
         }
      }

      var1.h();
   }

   private void e(zcfw var1, zbqg var2) throws Exception {
      String var3 = var1.a("sheetId");
      zut var4 = var2.b(zase.C(var3));
      String var5 = var1.a("refreshError");
      if (var5 != null) {
         var4.a().a(3, var5);
      }

      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(true) {
            while(var1.r() != 4) {
               var1.j();
               if (var1.r() != 1) {
                  var1.a();
               } else if ("row".equals(var1.p()) && !var1.n()) {
                  this.a(var1, var4);
               } else {
                  var1.a();
               }
            }

            var1.h();
            return;
         }
      }
   }

   private void a(zcfw var1, zut var2) throws Exception {
      String var3 = var1.a("r");
      zuq var4 = var2.e(zase.C(var3) - 1);
      var1.d();

      while(true) {
         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("cell".equals(var1.p()) && !var1.n()) {
               this.a(var1, var4);
            } else {
               var1.a();
            }
         }

         var1.h();
         return;
      }
   }

   private void a(zcfw var1, zuq var2) throws Exception {
      String var3 = var1.a("r");
      String var4 = var1.a("t");
      String var5 = null;
      var1.d();

      while(var1.r() != 4) {
         var1.j();
         if (var1.r() != 1) {
            var1.a();
         } else if ("v".equals(var1.p())) {
            var1.c(b(var1));
            var5 = var1.i();
            var1.c(false);
         } else {
            var1.a();
         }
      }

      var1.h();
      int var6 = -1;
      byte var7 = -1;
      Object var8 = null;
      if (var5 != null && var3 != null) {
         int[] var9 = new int[]{var7};
         int[] var10 = new int[]{var6};
         CellsHelper.a(var3, var9, var10);
         int var13 = var9[0];
         var6 = var10[0];
         if (!"n".equals(var4) && var4 != null) {
            if ("str".equals(var4)) {
               var8 = var5;
            } else if ("b".equals(var4)) {
               var8 = zase.ax(var5);
            } else if ("e".equals(var4)) {
               boolean var11 = true;
               boolean[] var12 = new boolean[]{var11};
               var8 = zsk.a(var5, var12);
               var11 = var12[0];
               if (!var11) {
                  var8 = var5;
               }
            } else {
               var8 = var5;
            }
         } else {
            var8 = zase.B(var5);
         }
      }

      if (var6 != -1) {
         var2.a(var6, var8);
      }

   }

   static boolean b(zcfw var0) {
      String var1 = var0.a("space", (String)null);
      return var1 != null;
   }

   private ArrayList f(zcfw var1) throws Exception {
      ArrayList var2 = new ArrayList();
      var1.d();

      while(var1.r() != 4) {
         var1.j();
         if (var1.r() != 1) {
            var1.a();
         } else if ("sheetName".equals(var1.p())) {
            String var3 = var1.a("val");
            var1.a();
            com.aspose.cells.b.a.a.ze.a(var2, (Object)var3);
         } else {
            var1.a();
         }
      }

      var1.h();
      return var2;
   }

   private void f(zcfw var1, zbqg var2) throws Exception {
      var1.d();

      while(var1.r() != 4) {
         var1.j();
         if (var1.r() != 1) {
            var1.a();
         } else if ("definedName".equals(var1.p())) {
            zuk var3 = new zuk(var2);
            var3.a(var1.a("name"));
            String var4 = var1.a("refersTo");
            String var5 = var1.a("sheetId");
            var1.a();
            if (var5 != null) {
               var3.c(zase.C(var5) + 1);
            }

            if (var4 != null && !"".equals(var4)) {
               var3.a(this.a.a.getWorksheets(), var4);
            }

            com.aspose.cells.b.a.a.ze.a(var2.b(), (Object)var3);
         } else {
            var1.a();
         }
      }

      var1.h();
   }

   private void g(zcfw var1) throws Exception {
      var1.j();
      if (var1.r() != 1 || !"externalLink".equals(var1.p())) {
         throw new CellsException(6, "externalLink root element eror");
      }
   }
}
